Skip to content

Introducing take Method #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

devajmeireles
Copy link

@devajmeireles devajmeireles commented Jun 2, 2025

Description

Hey, folks! After a long period, I'd like to get back to contributing to CodeIgniter 'cause this was my first framework during my career. This PR aims to introduce the take method, which can be used to perform two operations in a single interaction: get + flush, improving the dev experience in favor to avoid the need to manually perform these two operations individually

Demonstration

$siteName = service('settings')->take('App.siteName');

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@devajmeireles devajmeireles changed the title Feat/settings pull Introducing pull Method Jun 2, 2025
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for a PR! I'm not sure how often this get + flush combination is actually needed in practice, but if it is a common enough pattern to warrant its own method, then I think the implementation makes sense.

However, I have concerns about the pull() method name - it's quite ambiguous and doesn't clearly communicate what's happening.

What about alternatives like:

  • take() - this name suggests "taking" the value away from its source, implying both retrieval and removal
  • pop() - in array/stack terminology, pop() removes and returns the last element

@devajmeireles devajmeireles changed the title Introducing pull Method Introducing take Method Jun 2, 2025
@devajmeireles
Copy link
Author

Thank you for a PR! I'm not sure how often this get + flush combination is actually needed in practice, but if it is a common enough pattern to warrant its own method, then I think the implementation makes sense.

However, I have concerns about the pull() method name - it's quite ambiguous and doesn't clearly communicate what's happening.

What about alternatives like:

  • take() - this name suggests "taking" the value away from its source, implying both retrieval and removal
  • pop() - in array/stack terminology, pop() removes and returns the last element

As I have no disagreement regarding the name, I updated the PR adapting it to take, because I agree with your thoughts regarding this name.

@datamweb
Copy link
Contributor

datamweb commented Jun 2, 2025

@michalsn
Copy link
Member

michalsn commented Jun 2, 2025

One more thing - may I ask what is your use case for this method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants